[CakePHP] What is the best way to access another Model in a Controller?

Posted by kwokwai on Stack Overflow See other posts from Stack Overflow or by kwokwai
Published on 2010-05-12T18:04:42Z Indexed on 2010/05/12 19:34 UTC
Read the original article Hit count: 146

Filed under:

Hi all,

Say I got two Controllers like this
Table1sController, and Table2sController.
with corresponding Models:
Table1sModel, Table2sModel

In the Table1sController, I got this:
$this->Table1sModel->action();

Say I want to access some data in Table2sModel
How is it possible to do something like this in Table1sController
I have tried this in Table1sController:
$this->Table2sModel->action();
But I received an error message like this:
Undefined property: Table1sController::$Table2sModel

© Stack Overflow or respective owner

Related posts about cakephp